<template>
  <div class="message-list-cont">
      <div class="mess-wrapper" v-for="(item, index) in messageHanderListSli" :key="index">
          <div class="mess-left">
              <div :class="item.isread == 0 ? 'bg blue':'bg grey'">

              </div>
              <div class="info" @click="goToDetail(item,index)">
                  <div>您收到一条计划编码为 {{item.planid}} 的交办件，请前往<span class="choose">工作池-交办件</span>查看。</div>
              </div>
          </div>
          <div class="mess-right grey-font">{{item.appointeddate}}</div>
      </div>
      <div class="message-page">
        <Page v-show="messageHanderList.length > 0" @on-change="changePage" :current="currentPage" :total="total" :page-size="pageSize" />
      </div>
      <div class="tc" v-show="messageHanderList.length == 0">暂无通知</div>

  </div>
</template>
<script>
export default {
  name: 'messHander',
  props: ["messageHanderList",],
  data() {
    return {
        messageHanderListSli:[],
        currentPage:1,
        pageSize:10,
        total:1,
        // current: "messageSys",
        // messageSys: 1,
        // messageMeet: 0,
        // messageEdu: 5,
        // messageCheck: 0,
        // messageEval: 0,
        // messageKnow: 0,
    };
  },
  methods: {
      goToDetail(item,index){
        let cont = item.contno
        console.log(item.contno, cont,typeof(cont))
        let obj={
          type:7,
          contno: item.planid,
          // handovertype:cont ? '0' : '1'
        }
        this.api.updateWorkDiaryReadNotice(obj).then(res => {
          console.log(res)
          this.$store.commit('messageHasChangedFreshedQuickly', 'hander'+item.contno);
          sessionStorage.setItem("INSURANCE_TYPE","交办件")
          //先置为已读，再跳转
          this.$router.push({
              path:'/U/businessManagement/workPool',
              query: {
                  tabIndex: '4',
                  typeIndex: '4'
              }
          })
        })

      },
      changePage(num){
        this.currentPage = num
        this.messageHanderListSli = this.messageHanderList.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize)

      }

  },
  watch:{
    messageHanderList(){
      console.log("0handerwatch",this.messageHanderList)

      this.total = this.messageHanderList ? this.messageHanderList.length : 0
      this.messageHanderListSli = this.messageHanderList ? this.messageHanderList.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize) : []
      console.log(this.total,"112233")

    }
  },
  mounted() {
      console.log("000009")

      // console.log("0", this.this.messageHanderList)
      this.currentPage = 1
      this.total = this.messageHanderList ? this.messageHanderList.length : 0
      this.messageHanderListSli = this.messageHanderList.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize)

  }
};
</script>
<style lang="less">
@import "../index.less";
</style>